From 9aede683ea89cbc07cc3891fabb026f2405150d7 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 11 Mar 2015 18:33:17 -0700 Subject: [PATCH] Don't add non-compiled packages to the graph This was previously required to ensure that all relevant metadata files would remain in place and not get deleted, but this auto-clean behavior has since been removed so this should no longer be necessary. --- src/cargo/ops/cargo_rustc/job.rs | 16 +++------------- src/cargo/ops/cargo_rustc/job_queue.rs | 9 +-------- src/cargo/ops/cargo_rustc/mod.rs | 24 +++++------------------- 3 files changed, 9 insertions(+), 40 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/job.rs b/src/cargo/ops/cargo_rustc/job.rs index 8c10cba79..4467d37e6 100644 --- a/src/cargo/ops/cargo_rustc/job.rs +++ b/src/cargo/ops/cargo_rustc/job.rs @@ -22,7 +22,8 @@ impl R> FnBox for F { impl Work { pub fn new(f: F) -> Work - where F: FnOnce(Sender) -> CargoResult<()> + Send + 'static { + where F: FnOnce(Sender) -> CargoResult<()> + Send + 'static + { Work { inner: Box::new(f) } } @@ -37,21 +38,10 @@ impl Work { impl Job { /// Create a new job representing a unit of work. - pub fn new(dirty: Work, - fresh: Work) -> Job { + pub fn new(dirty: Work, fresh: Work) -> Job { Job { dirty: dirty, fresh: fresh } } - /// Create a new job which will run `fresh` if the job is fresh and - /// otherwise not run `dirty`. - /// - /// Retains the same signature as `new` for compatibility. This job does not - /// describe itself to the console. - pub fn noop(_dirty: Work, - fresh: Work) -> Job { - Job { dirty: Work::noop(), fresh: fresh } - } - /// Consumes this job by running it, returning the result of the /// computation. pub fn run(self, fresh: Freshness, tx: Sender) -> CargoResult<()> { diff --git a/src/cargo/ops/cargo_rustc/job_queue.rs b/src/cargo/ops/cargo_rustc/job_queue.rs index 7b042691b..6f2aab154 100644 --- a/src/cargo/ops/cargo_rustc/job_queue.rs +++ b/src/cargo/ops/cargo_rustc/job_queue.rs @@ -28,7 +28,6 @@ pub struct JobQueue<'a> { active: u32, pending: HashMap<(&'a PackageId, Stage), PendingBuild>, state: HashMap<&'a PackageId, Freshness>, - ignored: HashSet<&'a PackageId>, printed: HashSet<&'a PackageId>, } @@ -77,7 +76,6 @@ impl<'a> JobQueue<'a> { active: 0, pending: HashMap::new(), state: HashMap::new(), - ignored: HashSet::new(), printed: HashSet::new(), } } @@ -98,10 +96,6 @@ impl<'a> JobQueue<'a> { (pkg, jobs)); } - pub fn ignore(&mut self, pkg: &'a Package) { - self.ignored.insert(pkg.package_id()); - } - /// Execute all jobs necessary to build the dependency graph. /// /// This function will spawn off `config.jobs()` workers to build all of the @@ -212,8 +206,7 @@ impl<'a> JobQueue<'a> { // In general, we try to print "Compiling" for the first nontrivial task // run for a package, regardless of when that is. We then don't print // out any more information for a package after we've printed it once. - let print = !self.ignored.contains(&pkg.package_id()); - let print = print && !self.printed.contains(&pkg.package_id()); + let print = !self.printed.contains(&pkg.package_id()); if print && (stage == Stage::Libraries || (total_fresh == Dirty && running.len() > 0)) { self.printed.insert(pkg.package_id()); diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 397e758b0..2b4a4fa9e 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -142,7 +142,7 @@ pub fn compile_targets<'a, 'b>(env: &str, compiled.insert(dep.package_id().clone()); }); for dep in deps.iter() { - if dep == pkg { continue } + if dep == pkg || !compiled.contains(dep.package_id()) { continue } // Only compile lib targets for dependencies let targets = dep.targets().iter().filter(|target| { @@ -154,11 +154,10 @@ pub fn compile_targets<'a, 'b>(env: &str, return Err(human(format!("Package `{}` has no library targets", dep))) } - let compiled = compiled.contains(dep.package_id()); - try!(compile(&targets, dep, compiled, &mut cx, &mut queue)); + try!(compile(&targets, dep, &mut cx, &mut queue)); } - try!(compile(targets, pkg, true, &mut cx, &mut queue)); + try!(compile(targets, pkg, &mut cx, &mut queue)); // Now that we've figured out everything that we're going to do, do it! try!(queue.execute(cx.config)); @@ -184,24 +183,11 @@ pub fn compile_targets<'a, 'b>(env: &str, } fn compile<'a, 'b>(targets: &[&'a Target], pkg: &'a Package, - compiled: bool, cx: &mut Context<'a, 'b>, jobs: &mut JobQueue<'a>) -> CargoResult<()> { debug!("compile_pkg; pkg={}", pkg); let _p = profile::start(format!("preparing: {}", pkg)); - // Packages/targets which are actually getting compiled are constructed into - // a real job. Packages which are *not* compiled still have their jobs - // executed, but only if the work is fresh. This is to preserve their - // artifacts if any exist. - let job = if compiled { - Job::new as fn(Work, Work) -> Job - } else { - Job::noop as fn(Work, Work) -> Job - }; - - if !compiled { jobs.ignore(pkg); } - if targets.is_empty() { return Ok(()) } @@ -251,7 +237,7 @@ fn compile<'a, 'b>(targets: &[&'a Target], pkg: &'a Package, try!(work.call(desc_tx.clone())); dirty.call(desc_tx) }); - dst.push((job(dirty, fresh), freshness)); + dst.push((Job::new(dirty, fresh), freshness)); } // If this is a custom build command, we need to not only build the @@ -291,7 +277,7 @@ fn compile<'a, 'b>(targets: &[&'a Target], pkg: &'a Package, } let (dirty, fresh, freshness) = try!(custom_build::prepare(pkg, target, req, cx)); - run_custom.push((job(dirty, fresh), freshness)); + run_custom.push((Job::new(dirty, fresh), freshness)); } // If no build scripts were run, no need to compile the build script! -- 2.30.2